package sharedjplaylist.client.utils;

import com.google.gwt.i18n.client.DateTimeFormat;

public class CheckError {

    static String errorString = "";

    public static String checkPlaylist(String djnameString, String eventnameString, String dateString, String passwordString, String confirmPasswordString){
        errorString = "";

        if(djnameString == null || djnameString.isEmpty()){
            errorString += "DJ Nameを入力してください。<br/>";
        }

        if(eventnameString == null || eventnameString.isEmpty()){
            errorString += "Event Nameを入力してください。<br/>";
        }

        if(dateString == null || dateString.isEmpty()){
            errorString += "Dateを入力してください。<br/>";
        }else{
            DateTimeFormat formatter = DateTimeFormat.getFormat("yyyy/MM/dd");

            try {
                formatter.parseStrict(dateString);
            } catch (IllegalArgumentException e) {
                errorString += "Dateの形式が間違っています。(yyyy/MM/dd)<br/>";
            }
        }

        if(!passwordString.equals(confirmPasswordString)){
            errorString += "パスワードが一致していません。<br/>";
        }

        return errorString;
    }
}
